<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/3/3 0003
 * Time: 下午 20:52
 */

namespace Common\Model;

use Think\Model;

class BaseModel extends Model
{
    public function store($data){
        if ($this->create($data)){
//            echo 1;die;

            $action=isset($data[$this->pk])?'save':'add';
            //执行add返回自增id，save返回 1  0
            $res = $this->$action($data);

            return['valid'=>'success','msg'=>'操作成功','data'=>$res];
        }else{
            return['valid'=>'failed','msg'=>$this->getError()];
        }
    }




}